<table width="600" align="center">
	<tr>
    	<td>
        <?php
			//http://localhost:8888/EnrolmentSystem/Views/ReportCards/read.php?studentId=6291&schoolYear=2010-2011&action=read
			$uc = new StudentController();
			$u = $uc->read($_REQUEST['studentId']);
			$u = mysql_fetch_array($u);
        ?>
        Name: <?php echo $u['Name']; ?>
		</td>
    </tr>
    <tr><td>GRADE / SECTION: <?php echo $u['Name']; ?></td></tr>
    <tr><td>SEX: <?php echo $u['Sex']; ?></td></tr>
    <tr><td>AGE: <?php echo $u['Age']; ?></td></tr>
</table>
<table class="report_card" width="600" border="1" align="center">
<tr><td>
<?php
	echo $_REQUEST['action'] == 'read' ? 'View Grades' : 'Update Grades';
?>
</td></tr></table>
<table class="report_card" width="600" height="300" border="1" align="center">
  <tr>
    <th width="200" rowspan="2" align="center">LEARNING AREAS</td>
    <th colspan="4" align="center">PERIODIC RATINGS</td>
    <th width="62" rowspan="2" align="center">Final Rating</td>
  </tr>
  <tr>
    <th align="center">1st</td>
    <th align="center">2nd</td>
    <th align="center">3rd</td>
    <th align="center">4th</td>
  </tr>
  <?php
	//Render table data for all subjects (<td>).
	$rc = new ReportCardController();
	$sc = new SubjectController();
	$r = $sc->getAllSubjects();
	$rm = @!empty($_REQUEST['action']);
	while($o = mysql_fetch_object($r))
	{
		$name = $o->Name;
		$r = $rc->getGradePerSubject($name, 
										$_REQUEST['studentId'], 
										$_REQUEST['schoolYear']);
		echo "<tr><td>$name</td>";
		while($o = @mysql_fetch_object($r))
		{
			//TODO:		Push to array and provide null values to grades 
			//so that empty tables can have spaces instead of blanks.
			$n = $o->Grade;
			echo '<td width="50" height="50" align="center">';
				if($rm == 'update')
				{
					$id = $o->Id;
					echo '<input type="text" name="grades[id][]" ' . 
							'value="' . $n . '" />';
				}
				else if($rm == 'read')
				{
					echo $n;
				}
			echo '</td>';
		}
		echo '</tr>';
	}
  ?>
</table>